<#setting classic_compatible=true> <#assign
	base=request.contextPath /> <!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>客户端首页</title>
    <script th:src="@{/jquery/jquery.min.js}"></script>
    <script src="${base}/zhgl-jzstyxx-manage/vendors/jquery/dist/jquery.min.js"></script>
	<script src="${base}/zhgl-jzstyxx-manage/js/login/jquery.cookie.js"></script>
	<script src="${base}/zhgl-jzstyxx-manage/js/login/jquery.session.js"></script>
</head>
<body>

请输入您的昵称<input type="text" id="username">
         <input type="button" value="连接" onclick="connect()"></input>   <br>
请填写要发送的内容<input type="text" id="writeMsg"></input>    
         <input type="button" value="发送" onclick="sendMsg()"></input>   

<script type="text/javascript">
var ws = null;    
function connect(){
	if($("#username").val()!=null && $("#username").val()!=""){
		if ('WebSocket' in window){
		     //ws = new WebSocket("ws://localhost:8080/socketServer/"+$("#username").val());
			ws = new WebSocket("ws://localhost:8080/zhgl-jzstyxx-manage/socketServer/"+$("#username").val());   
		}    
	    else if ('MozWebSocket' in window){
	        //ws = new MozWebSocket("/socketServer/"+$("#username").val());    
	    	ws = new MozWebSocket("ws://localhost:8080/zhgl-jzstyxx-manage/socketServer/"+$("#username").val());  
	    }
	    else{
	        alert("该浏览器不支持websocket");    
	    }    
	        
	        
	    ws.onmessage = function(evt) {    
	    	//
	        alert(evt.data);    
	    	console.log("服务器发来的消息为："+evt.data);
	    };    
	        
	    ws.onclose = function(evt) {    
	        alert("连接中断");    
	    };    
	        
	    ws.onopen = function(evt) {    
	        alert("连接成功");    
	    };  
	}else{
		alert("请输入您的昵称");
	}
}    
    
function sendMsg() {    
    ws.send($("#writeMsg").val());    
}    
</script>
</body>
</html>